package top.huhuiyu.springboot2.entity;

public class BaseDataResult<T> extends BaseResult {
  private T data;

  public static <T> BaseDataResult<T> ok(T data) {
    BaseDataResult<T> result = new BaseDataResult<>();
    result.setCode(200);
    result.setSuccess(true);
    result.setData(data);
    result.setMessage("");
    return result;
  }

  public static <T> BaseDataResult<T> fail(String message, Class<T> clazz) {
    BaseDataResult<T> result = new BaseDataResult<>();
    result.setCode(200);
    result.setSuccess(true);
    result.setMessage(message);
    return result;
  }

  @Override
  public String toString() {
    return "BaseDataResult{" + "data=" + data + "} " + super.toString();
  }

  public T getData() {
    return data;
  }

  public void setData(T data) {
    this.data = data;
  }
}
